// LemCoop
// Copyright (C) 2013  Oliver Naumann <bldrax@gmail.com>

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#ifndef LEMC_GROUNDMASK_H
#define LEMC_GROUNDMASK_H

#include <vector>

#include "../util/logmanager.h"

/*
* This class contains one of the most important informations of the game: It defines, where there is ground to walk
* on or dig or bash into, steel which can't be destroyed and other types of stuff. Essentially, this defines the
* world and its possibilities for interaction. Everything is independant from how the world looks - meaning that
* there can be pixels where actually no ground is (but that usually should not be the case).
*/
class GroundMask
{
private:
	// Contains the array of pixels with the information.
	char* m_mask;

	// Horizontal size of the mask/world.
	int m_size_x;

	// Vertical size of the mask/world.
	int m_size_y;

public:
	/*
	* The kind of attributes, a pixel can have. Each pixel can have exactly one property.
	*/
	enum Types
	{
		AIR = 0,
		GROUND,
		STEEL,
		BRIDGE
	};

	/*
	* Contructs the ground mask and initializes the array with open space.
	*
	* @param size_x The width of the mask.
	* @param size_y The height of the mask.
	*/
	GroundMask(int size_x, int size_y);

	/*
	* Destroys the mask after it is not needed anymore.
	*/
	~GroundMask();

	/*
	* Changes the property of one pixel.
	*
	* @param x The x position of the pixel to be modified.
	* @param y The y position of the pixel to be modified.
	* @param value The new property of the pixel, should be a value from the enumeration 'Types'.
	*
	* @return True if the pixel was set, false else.
	*/
	bool SetPixel(int x, int y, char value);

	/*
	* Obtains the property of one pixel.
	*
	* @param x The x position of the pixel.
	* @param y The y position of the pixel.
	* @param value This is where the property value is stored if it can be obtained. It should be a value from the
	* enumeration 'Types'.
	*
	* @return True if the pixel information could be obtained, false else.
	*/
	bool GetPixel(int x, int y, char &value);
};

#endif;